package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"shopexam/api/internal/config"
	"shopexam/api/internal/middleware"
	"shopexam/shoprpc/shoprpcclient"
)

type ServiceContext struct {
	Config              config.Config
	ShopRpc             shoprpcclient.Shoprpc
	UserAgentMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		ShopRpc:             shoprpcclient.NewShoprpc(zrpc.MustNewClient(c.ShopRpc)),
		UserAgentMiddleware: middleware.NewUserAgentMiddleware().Handle,
	}
}
